package com.xyhy.starter.codegen.model;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * @author robert
 * @since 2025-06-11
 */
@Getter
@Setter
@Accessors(chain = true)
public class EntityDataBean {
  @ApiModelProperty("实体名称（英文名）")
  private String name;

  @ApiModelProperty("实体名称（中文名）")
  private String title;

  @ApiModelProperty("当前实体类对应controller的requestMapping")
  private String baseUrl;

  @ApiModelProperty("字段")
  private List<Field> fields = new ArrayList<>();

  @ApiModelProperty("计算字段：是否有 boolean 字段")
  private boolean hasBooleanField;

  private final String symbol = "#";

  @Getter
  @Setter
  @Accessors(chain = true)
  public static class Field {
    @ApiModelProperty("名称")
    private String name;

    @ApiModelProperty("标题")
    private String title;

    @ApiModelProperty("类型")
    private Class<?> type;

    @ApiModelProperty("类型名称")
    private String typeName;

    @ApiModelProperty("是否非空")
    private Boolean notNull;

    @ApiModelProperty("字符串最大长度")
    private Integer maxLength;

    @ApiModelProperty("计算属性：是否为外键")
    private Boolean isForeignKey;

    @ApiModelProperty("计算属性：外键data集合名称")
    private String foreignDataName;

    @ApiModelProperty("计算属性：是否为枚举")
    private Boolean isEnum;

    @ApiModelProperty("计算属性：是否为 Tag 枚举")
    private Boolean isTagEnum;

    @ApiModelProperty("计算属性：枚举data集合名称")
    private String enumDataName;

    @ApiModelProperty("计算属性：Tag 枚举对象名称")
    private String tagEnumVOName;

    @ApiModelProperty("计算属性：el-table-column节点prop属性，针对外键，将 Id 替换为 Name，如 supplyId 替换为 supplyName")
    private String columnProp;

    @ApiModelProperty("计算属性：是否为 textArea 类型")
    private Boolean isTextArea;

  }

}
